var prefix="/wxuser";
$(function () {
	valid();
	$(".chosen-select").chosen({
	    no_results_text: "没有找到结果！",//搜索无结果时显示的提示
	    search_contains:true,   //关键字模糊搜索，设置为false，则只从开头开始匹配
	    allow_single_deselect:true, //是否允许取消选择
	    max_selected_options:5  //当select为多选时，最多选择个数
	});
	
});

$.validator.setDefaults({
    submitHandler: function() {
    	move();
    }
});


function move(){
	var rows=parent.checkSelect();
	var gid=$("#group").val();
	console.log(gid);
	if(!rows||!gid)
	return;
    var config={
			url : prefix+"/move",
			data: {"ids" : rows,"gid":gid},
			sureDo:true,
			msg:"确定要该该用户打标签？"
	}
	EasyAjax.post(config,function(r){
		layer.msg(r.msg);
		if (r.code == 0){
			parent.reLoad();
			var index = parent.layer.getFrameIndex(window.name); // 获取窗口索引
			parent.layer.close(index);
		} 
	});
}


function valid(){
    var icon = "<i class='fa fa-times-circle'></i>";
    $("#signupForm").validate({
        rules:{
        	group: {
        		 required: true,
        	},
        },
        messages: {
        	group: {
        		required:icon + "请选择分组",
        	},
        }
    });
}

